<template>
  <el-dialog class="dia-style" title="操作日志详情" :visible.sync="open" width="800px" append-to-body>
    <hk-details :details-list="detailsList" :formData="form">
      <template #logInfo>
        <span>{{ form.createBy }}/{{ form.reqIp }}</span>
      </template>
      <template #status>
        {{ form.status == 0 ? '成功' : '失败' }}
      </template>
      <template #exception>
        {{ form.status == 0 ? form.respContent : form.exception }}
      </template>
    </hk-details>
    <div slot="footer" class="dialog-footer">
      <el-button @click="open = false">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import HkDetails from '@/components/HKDetails'
export default {
  components: { HkDetails },
  props: {
    formData: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  data() {
    return {
      open: false,
      form: {},
      detailsList: [
        { label: '操作模块', span: 12, field: 'module' },
        { label: '操作类型', span: 12, field: 'logTypeName' },
        { label: '登录信息', span: 12, field: 'logInfo', type: 'slot' },
        { label: '操作角色', span: 12, field: 'roleName' },
        { label: '请求地址', span: 12, field: 'reqUri' },
        { label: '请求方式', span: 12, field: 'reqType' },
        { label: '操作方法', field: 'reqMethod' },
        { label: '操作详情', field: 'logInfo' },
        { label: '响应内容', field: 'exception' },
        { label: '操作状态', span: 12, field: 'status', type: 'slot' },
        { label: '操作时间', span: 12, field: 'createDate' },
      ],
    }
  },
  watch: {
    formData: {
      handler(newVal) {
        this.form = newVal
      },
    },
  },
  methods: {
    // 操作日志类型字典翻译
    typeFormat(row, column) {
      return this.selectDictLabel(this.dict.type.sys_oper_type, row.businessType)
    },
  },
}
</script>

<style scoped></style>
